﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:data="clr-namespace:MissedMemo.MeatAndCheeseDisc.OrderEntryService.OrderProcessing;assembly=OrderEntryServiceAbstraction"
    xmlns:local="clr-namespace:MissedMemo.MeatAndCheeseDisc.OrderEntry" >
    
    
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="resCommonStyles.xaml" />
        <ResourceDictionary Source="resOrdersListStyles.xaml" />
    </ResourceDictionary.MergedDictionaries>

    
    <local:OrderStateToStringConverter x:Key="OrderStateToStringConverter" />
    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    
    
    <DataTemplate x:Key="OrderTemplate" DataType="{x:Type data:Order}" >

        <Border Style="{StaticResource OrderListItemStyle}" >      
            <Grid >

                <Grid.Resources>
                    <!-- TextBlock.VerticalAlignment CANNOT be applied via border style -->
                    <Style TargetType="TextBlock">
                        <Setter Property="VerticalAlignment" Value="Center" />
                    </Style>
                </Grid.Resources>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*" />
                    <ColumnDefinition Width="4*"  />
                    <ColumnDefinition Width="5*"  />
                    <ColumnDefinition Width="2*"  />
                    <ColumnDefinition Width="1*"  />
                    <ColumnDefinition Width="auto"  />
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Column="0" Text="{Binding NowServingNumber,
                    Converter={StaticResource FormattedTextConverter}, ConverterParameter='# {0}'}" />
                
                <TextBlock Grid.Column="1" Text="{Binding Customer.Name}" />
                
                <TextBlock Grid.Column="2" FontSize="13" Foreground="{StaticResource brushStatusText}" HorizontalAlignment="Left" >
                    <TextBlock.Text>
                        <MultiBinding Converter="{StaticResource OrderStateToStringConverter}" >
                            <Binding Path="Timer.ElapsedTime" />
                            <Binding Path="ProcessingState" />
                            <Binding Path="DateTimeOrderExpectedComplete" />
                            <Binding Path="DateTimeOrderCompleted" />
                            <Binding Path="DeliveryRequested" />
                            <Binding Path="DeliveryDriver" />
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
                
                <Image Grid.Column="3" Source="Resources\Delivery.gif" Visibility="{Binding DeliveryRequested,
                    Converter ={StaticResource BooleanToVisibilityConverter}}" />
                
                <Grid Grid.Column="4" >
                    <Image Source="Resources\Pizza.png" />
                    <TextBlock Text="{Binding NumPizzas}" FontSize="14" Foreground="{StaticResource brushNumPizzasText}" />
                </Grid>
                
                <Border Grid.ColumnSpan="6" x:Name="OrderHighlight" Style="{StaticResource OrderHighlightStyle}" />
                
                <Button Grid.Column="5" Content="X" Command="ApplicationCommands.Delete" ToolTip="Delete/Cancel Order" />
                
            </Grid>
        </Border>
        
        <DataTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True" >
                <Setter TargetName="OrderHighlight" Property="Opacity" Value="1" />
            </Trigger>
        </DataTemplate.Triggers>

    </DataTemplate>
    

</ResourceDictionary>